package baoxin.com.robotcoach;

import android.content.Intent;
import android.media.MediaPlayer;
import android.net.Uri;
import android.os.Bundle;
import android.widget.MediaController;
import android.widget.VideoView;

import baoxin.com.robotcoach.utils.MyLog;

public class FullScreenActivity extends BaseActivity {

    private VideoView videoView;


    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_full_screen);
        videoView = findViewById(R.id.video_view);
        MyLog.d("FullScreenActivity", "onCreate");
        String path = "android.resource://" + getPackageName() + "/" + R.raw.keerquxian;
        int current;
        Intent it = getIntent();
        path = it.getStringExtra("path");
        current = it.getIntExtra("currentProgress", 0);
        Uri uri = Uri.parse(path);
        videoView.setVideoURI(uri);
        videoView.setMediaController(new MediaController(this));
        videoView.setOnCompletionListener(new MediaPlayer.OnCompletionListener() {
            @Override
            public void onCompletion(MediaPlayer mp) {
                finish();
            }
        });
        videoView.setBackground(null);
        videoView.seekTo(current);
        videoView.start();

    }

    @Override
    public void finish() {

        Intent back = new Intent();
        back.putExtra("currentProgress", videoView.getCurrentPosition());
        setResult(VideoListActivity.FULL_SCREEN_FINISH, back);
        super.finish();

    }
}
